﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebCinesItech
{
    public partial class frmConsultaPelicula : System.Web.UI.Page
    {
        localhost.Service oWs = new localhost.Service();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
            }else{
                DataSet tblcines = new DataSet();
                DataSet tblPelicula = new DataSet();


                tblcines = oWs.ListarCines();
                tblPelicula = oWs.ListarPeli();


                cboListaCine.DataSource = tblcines;
                cboListaCine.DataTextField = "Cine";
                cboListaCine.DataValueField = "Codigo";
                cboListaCine.DataBind();

                cboListaPelicula.DataSource = tblPelicula;
                cboListaPelicula.DataTextField = "titulo";
                cboListaPelicula.DataValueField = "pelicula_ID";
                cboListaPelicula.DataBind();
            }

                
            
        

        }

        protected void btnConsulta_Click(object sender, EventArgs e)
        {
            DataSet tbldatos = new DataSet();
            if (rbcines.Checked == false && rdbPelicula.Checked == false)
            {
                lblMensaje.Visible = true;
              
                lblMensaje.Text = "No hay Información que mostrar";
            }
            

            if (rbcines.Checked==true)
            {
                lblMensaje.Visible = false;
            tbldatos = oWs.ListarPeliculas(cboListaCine.SelectedValue.ToString(), "");
            dgListado.DataSource = tbldatos.Tables[0];
            dgListado.DataBind();
            }

              if (rdbPelicula.Checked==true)
            {
                lblMensaje.Visible = false;
            tbldatos = oWs.ListarPeliculas("", cboListaPelicula.SelectedValue.ToString());
            dgListado.DataSource = tbldatos.Tables[0];
            dgListado.DataBind();
            }



          
        }

    
        protected void rdbPelicula_CheckedChanged(object sender, EventArgs e)
        {
            rbcines.Checked = false;
            Label1.Visible = false;
            cboListaCine.Visible = false;
            Label3.Visible = true;
            cboListaPelicula.Visible = true;
        }

        protected void rbcines_CheckedChanged(object sender, EventArgs e)
        {
            if (rbcines.Checked == true)
            {
                rdbPelicula.Checked = false;
                Label1.Visible = true;
                cboListaCine.Visible = true;
                Label3.Visible = false;
                cboListaPelicula.Visible = false;
            }
        }
    }
}